package shangji2.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import shangji2.Printer;
import shangji2.Mohe.CaiMohe;
import shangji2.Mohe.HeiMohe;
import shangji2.Zhi.A4zhi;

@Configuration
// 移除@ComponentScan，避免与@Bean定义的Bean冲突
public class PrinterConfig {

    // 创建彩色打印机实例
    @Bean("colorPrinter")
    public Printer colorPrinter() {
        return new Printer(new CaiMohe());
    }

    // 创建黑白打印机实例
    @Bean("bwPrinter")
    public Printer bwPrinter() {
        Printer printer = new Printer(new HeiMohe());
        printer.setZhi(new A4zhi());  // 设置A4纸张
        return printer;
    }

    // 直接定义需要的组件，避免扫描带来的冲突
    @Bean("caiMohe")
    public CaiMohe caiMohe() {
        return new CaiMohe();
    }

    @Bean("heiMohe")
    public HeiMohe heiMohe() {
        return new HeiMohe();
    }

    @Bean("a4zhi")
    public A4zhi a4zhi() {
        return new A4zhi();
    }

    @Bean("b5zhi")
    public A4zhi b5zhi() {
        return new A4zhi();
    }
}